#include "gtest/gtest.h"

#include "DemoContainerCommon.h"
#include "DemoContainer.h"
#include "DemoContainerUnitTestRemoveItem.h"

DemoContainerSuiteStubRemoveItemTest::DemoContainerSuiteStubRemoveItemTest()
{
  uintTestData_.insert(common::UnitTestData::value_type(0, "JHEWRIHUW&^()&()#$%^$%^&*JHGSDGAISDASODUS)(&*&^()^&*("));
  uintTestData_.insert(common::UnitTestData::value_type(1, "asdfdds7984316876834534654kghgpoeuferhnJNKDGFD:SJFL>:>{}:L:"));
  uintTestData_.insert(common::UnitTestData::value_type(2, "D$^*)#^GFHJL"));
  uintTestData_.insert(common::UnitTestData::value_type(3, "Ddwfaf168/--%^^&()^%%KjhlkjHhlhkl"));
  uintTestData_.insert(common::UnitTestData::value_type(4, "~!@#$%^&*()~!@#$%^&*()!@#$%^&*WERTYUISDFGHJCVBNMGHJTYUI"));
}

DemoContainerSuiteDriverRemoveItemTest::DemoContainerSuiteDriverRemoveItemTest()
{
  uintTestData_.insert(common::UnitTestData::value_type(0, "SDFADSFUNAS'SDIF[PDF"));
  uintTestData_.insert(common::UnitTestData::value_type(1, "~!@#$%^&*()~!@#$%^&*()!@#$%^&*WERTYUISDFGHJCVBNMGHJTYUI"));
  uintTestData_.insert(common::UnitTestData::value_type(2, "!@#$%^&*@#$%^&*$%^&*%^&*$%^&*$%^&$%^&*$%^&*$%^&*$%^&*(@#$%^&*()#$%^&*"));
  uintTestData_.insert(common::UnitTestData::value_type(3, "%^&*%^&*(34567890456789#$%^&$%^&8456789$%^&*(ughj<RTYUIOVBNM%^&*"));
  uintTestData_.insert(common::UnitTestData::value_type(4, "@#$%^&3$%^&*$%^&*34567834567899234567894567893456ERTYUIDFGHJVBNFG{:>}?}?FGHJK"));
}

TEST_F(DemoContainerSuiteStubRemoveItemTest, TestRemoveItemWhen0)
{
  democontainer::DemoContainer container; 
  EXPECT_FALSE(container.remove_item( ZERO ) );
}

TEST_F(DemoContainerSuiteStubRemoveItemTest, TestRemoveItemMinus)
{
  democontainer::DemoContainer container; 
  EXPECT_FALSE(container.remove_item( MINUSONE ) );
}

TEST_F(DemoContainerSuiteStubRemoveItemTest, TestRemoveItemWhenEqualNum )
{
  democontainer::DemoContainer container; 
  common::UnitTestData tmpData = this->get_usedata();

  for ( common::UnitTestData::iterator iter = tmpData.begin();
    iter != tmpData.end(); iter++)
  {
    container.add_item( iter->second );
  }

  EXPECT_FALSE( container.remove_item( (common::Index)(tmpData.size()) ) );
}

TEST_F(DemoContainerSuiteStubRemoveItemTest, TestRemoveItemWhenGreaterNumThan1 )
{
  democontainer::DemoContainer container; 
  common::UnitTestData tmpData = this->get_usedata();

  for ( common::UnitTestData::iterator iter = tmpData.begin();
    iter != tmpData.end(); iter++)
  {
    container.add_item( iter->second );
  }

  EXPECT_FALSE( container.remove_item( (common::Index)(tmpData.size()) + 1 ) );
}

TEST_F(DemoContainerSuiteStubRemoveItemTest, TestRemoveItemWhenGreaterNumThan100 )
{
  democontainer::DemoContainer container; 
  common::UnitTestData tmpData = this->get_usedata();

  for ( common::UnitTestData::iterator iter = tmpData.begin();
    iter != tmpData.end(); iter++)
  {
    container.add_item( iter->second );
  }

  EXPECT_FALSE( container.remove_item( (common::Index)(tmpData.size()) + 100 ) );
}

TEST_F(DemoContainerSuiteDriverRemoveItemTest, TestRemoveItemWhen5Data )
{
  democontainer::DemoContainer container; 
  common::UnitTestData tmpData = this->get_usedata();

  for ( common::Container::size_type i = 0; i < tmpData.size(); i++ )
  {
    container.add_item( tmpData[i] );
  }

  EXPECT_TRUE(container.remove_item(ZERO));
  EXPECT_EQ(FOUR, container.get_size());

  EXPECT_TRUE(container.remove_item(ZERO));
  EXPECT_EQ(THREE, container.get_size());

  EXPECT_TRUE(container.remove_item(ZERO));
  EXPECT_EQ(TWO, container.get_size());

  EXPECT_TRUE(container.remove_item(ZERO));
  EXPECT_EQ(ONE, container.get_size());

  EXPECT_TRUE(container.remove_item(ZERO));
  EXPECT_EQ(ZERO, container.get_size());
}
